/**
 * (c) 2007 Joern Dinkla, www.dinkla.net
 * 
 *
 * $Id$
 */
package CWM.Relational.provider;

import CWM.Relational.util.RelationalAdapterFactory;

import java.util.ArrayList;
import java.util.Collection;

import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;

import org.eclipse.emf.edit.provider.ChangeNotifier;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.IChangeNotifier;
import org.eclipse.emf.edit.provider.IDisposable;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.INotifyChangedListener;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;

/**
 * This is the factory that is used to provide the interfaces needed to support Viewers.
 * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}.
 * The adapters also support Eclipse property sheets.
 * Note that most of the adapters are shared among multiple instances.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public class RelationalItemProviderAdapterFactory extends RelationalAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable {
	/**
	 * This keeps track of the root adapter factory that delegates to this adapter factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ComposedAdapterFactory parentAdapterFactory;

	/**
	 * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected IChangeNotifier changeNotifier = new ChangeNotifier();

	/**
	 * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected Collection<Object> supportedTypes = new ArrayList<Object>();

	/**
	 * This constructs an instance.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public RelationalItemProviderAdapterFactory() {
		supportedTypes.add(IEditingDomainItemProvider.class);
		supportedTypes.add(IStructuredItemContentProvider.class);
		supportedTypes.add(ITreeItemContentProvider.class);
		supportedTypes.add(IItemLabelProvider.class);
		supportedTypes.add(IItemPropertySource.class);
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Relational.Catalog} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected CatalogItemProvider catalogItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Relational.Catalog}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createCatalogAdapter() {
		if (catalogItemProvider == null) {
			catalogItemProvider = new CatalogItemProvider(this);
		}

		return catalogItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Relational.Schema} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SchemaItemProvider schemaItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Relational.Schema}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createSchemaAdapter() {
		if (schemaItemProvider == null) {
			schemaItemProvider = new SchemaItemProvider(this);
		}

		return schemaItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Relational.ColumnSet} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ColumnSetItemProvider columnSetItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Relational.ColumnSet}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createColumnSetAdapter() {
		if (columnSetItemProvider == null) {
			columnSetItemProvider = new ColumnSetItemProvider(this);
		}

		return columnSetItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Relational.NamedColumnSet} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected NamedColumnSetItemProvider namedColumnSetItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Relational.NamedColumnSet}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createNamedColumnSetAdapter() {
		if (namedColumnSetItemProvider == null) {
			namedColumnSetItemProvider = new NamedColumnSetItemProvider(this);
		}

		return namedColumnSetItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Relational.Table} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected TableItemProvider tableItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Relational.Table}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createTableAdapter() {
		if (tableItemProvider == null) {
			tableItemProvider = new TableItemProvider(this);
		}

		return tableItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Relational.View} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ViewItemProvider viewItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Relational.View}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createViewAdapter() {
		if (viewItemProvider == null) {
			viewItemProvider = new ViewItemProvider(this);
		}

		return viewItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Relational.QueryColumnSet} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected QueryColumnSetItemProvider queryColumnSetItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Relational.QueryColumnSet}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createQueryColumnSetAdapter() {
		if (queryColumnSetItemProvider == null) {
			queryColumnSetItemProvider = new QueryColumnSetItemProvider(this);
		}

		return queryColumnSetItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Relational.SQLDistinctType} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SQLDistinctTypeItemProvider sqlDistinctTypeItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Relational.SQLDistinctType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createSQLDistinctTypeAdapter() {
		if (sqlDistinctTypeItemProvider == null) {
			sqlDistinctTypeItemProvider = new SQLDistinctTypeItemProvider(this);
		}

		return sqlDistinctTypeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Relational.SQLSimpleType} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SQLSimpleTypeItemProvider sqlSimpleTypeItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Relational.SQLSimpleType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createSQLSimpleTypeAdapter() {
		if (sqlSimpleTypeItemProvider == null) {
			sqlSimpleTypeItemProvider = new SQLSimpleTypeItemProvider(this);
		}

		return sqlSimpleTypeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Relational.SQLStructuredType} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SQLStructuredTypeItemProvider sqlStructuredTypeItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Relational.SQLStructuredType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createSQLStructuredTypeAdapter() {
		if (sqlStructuredTypeItemProvider == null) {
			sqlStructuredTypeItemProvider = new SQLStructuredTypeItemProvider(this);
		}

		return sqlStructuredTypeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Relational.Column} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ColumnItemProvider columnItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Relational.Column}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createColumnAdapter() {
		if (columnItemProvider == null) {
			columnItemProvider = new ColumnItemProvider(this);
		}

		return columnItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Relational.Procedure} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ProcedureItemProvider procedureItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Relational.Procedure}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createProcedureAdapter() {
		if (procedureItemProvider == null) {
			procedureItemProvider = new ProcedureItemProvider(this);
		}

		return procedureItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Relational.Trigger} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected TriggerItemProvider triggerItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Relational.Trigger}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createTriggerAdapter() {
		if (triggerItemProvider == null) {
			triggerItemProvider = new TriggerItemProvider(this);
		}

		return triggerItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Relational.SQLIndex} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SQLIndexItemProvider sqlIndexItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Relational.SQLIndex}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createSQLIndexAdapter() {
		if (sqlIndexItemProvider == null) {
			sqlIndexItemProvider = new SQLIndexItemProvider(this);
		}

		return sqlIndexItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Relational.UniqueConstraint} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected UniqueConstraintItemProvider uniqueConstraintItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Relational.UniqueConstraint}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createUniqueConstraintAdapter() {
		if (uniqueConstraintItemProvider == null) {
			uniqueConstraintItemProvider = new UniqueConstraintItemProvider(this);
		}

		return uniqueConstraintItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Relational.ForeignKey} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ForeignKeyItemProvider foreignKeyItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Relational.ForeignKey}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createForeignKeyAdapter() {
		if (foreignKeyItemProvider == null) {
			foreignKeyItemProvider = new ForeignKeyItemProvider(this);
		}

		return foreignKeyItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Relational.SQLIndexColumn} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SQLIndexColumnItemProvider sqlIndexColumnItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Relational.SQLIndexColumn}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createSQLIndexColumnAdapter() {
		if (sqlIndexColumnItemProvider == null) {
			sqlIndexColumnItemProvider = new SQLIndexColumnItemProvider(this);
		}

		return sqlIndexColumnItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Relational.PrimaryKey} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected PrimaryKeyItemProvider primaryKeyItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Relational.PrimaryKey}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createPrimaryKeyAdapter() {
		if (primaryKeyItemProvider == null) {
			primaryKeyItemProvider = new PrimaryKeyItemProvider(this);
		}

		return primaryKeyItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Relational.Row} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected RowItemProvider rowItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Relational.Row}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createRowAdapter() {
		if (rowItemProvider == null) {
			rowItemProvider = new RowItemProvider(this);
		}

		return rowItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Relational.ColumnValue} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ColumnValueItemProvider columnValueItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Relational.ColumnValue}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createColumnValueAdapter() {
		if (columnValueItemProvider == null) {
			columnValueItemProvider = new ColumnValueItemProvider(this);
		}

		return columnValueItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Relational.CheckConstraint} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected CheckConstraintItemProvider checkConstraintItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Relational.CheckConstraint}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createCheckConstraintAdapter() {
		if (checkConstraintItemProvider == null) {
			checkConstraintItemProvider = new CheckConstraintItemProvider(this);
		}

		return checkConstraintItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Relational.RowSet} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected RowSetItemProvider rowSetItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Relational.RowSet}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createRowSetAdapter() {
		if (rowSetItemProvider == null) {
			rowSetItemProvider = new RowSetItemProvider(this);
		}

		return rowSetItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Relational.SQLParameter} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SQLParameterItemProvider sqlParameterItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Relational.SQLParameter}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createSQLParameterAdapter() {
		if (sqlParameterItemProvider == null) {
			sqlParameterItemProvider = new SQLParameterItemProvider(this);
		}

		return sqlParameterItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link CWM.Relational.Relational_container} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected Relational_containerItemProvider relational_containerItemProvider;

	/**
	 * This creates an adapter for a {@link CWM.Relational.Relational_container}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createRelational_containerAdapter() {
		if (relational_containerItemProvider == null) {
			relational_containerItemProvider = new Relational_containerItemProvider(this);
		}

		return relational_containerItemProvider;
	}

	/**
	 * This returns the root adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ComposeableAdapterFactory getRootAdapterFactory() {
		return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
	}

	/**
	 * This sets the composed adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) {
		this.parentAdapterFactory = parentAdapterFactory;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean isFactoryForType(Object type) {
		return supportedTypes.contains(type) || super.isFactoryForType(type);
	}

	/**
	 * This implementation substitutes the factory itself as the key for the adapter.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter adapt(Notifier notifier, Object type) {
		return super.adapt(notifier, this);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object adapt(Object object, Object type) {
		if (isFactoryForType(type)) {
			Object adapter = super.adapt(object, type);
			if (!(type instanceof Class) || (((Class<?>)type).isInstance(adapter))) {
				return adapter;
			}
		}

		return null;
	}

	/**
	 * This adds a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void addListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.addListener(notifyChangedListener);
	}

	/**
	 * This removes a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void removeListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.removeListener(notifyChangedListener);
	}

	/**
	 * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void fireNotifyChanged(Notification notification) {
		changeNotifier.fireNotifyChanged(notification);

		if (parentAdapterFactory != null) {
			parentAdapterFactory.fireNotifyChanged(notification);
		}
	}

	/**
	 * This disposes all of the item providers created by this factory. 
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void dispose() {
		if (catalogItemProvider != null) catalogItemProvider.dispose();
		if (schemaItemProvider != null) schemaItemProvider.dispose();
		if (columnSetItemProvider != null) columnSetItemProvider.dispose();
		if (namedColumnSetItemProvider != null) namedColumnSetItemProvider.dispose();
		if (tableItemProvider != null) tableItemProvider.dispose();
		if (viewItemProvider != null) viewItemProvider.dispose();
		if (queryColumnSetItemProvider != null) queryColumnSetItemProvider.dispose();
		if (sqlDistinctTypeItemProvider != null) sqlDistinctTypeItemProvider.dispose();
		if (sqlSimpleTypeItemProvider != null) sqlSimpleTypeItemProvider.dispose();
		if (sqlStructuredTypeItemProvider != null) sqlStructuredTypeItemProvider.dispose();
		if (columnItemProvider != null) columnItemProvider.dispose();
		if (procedureItemProvider != null) procedureItemProvider.dispose();
		if (triggerItemProvider != null) triggerItemProvider.dispose();
		if (sqlIndexItemProvider != null) sqlIndexItemProvider.dispose();
		if (uniqueConstraintItemProvider != null) uniqueConstraintItemProvider.dispose();
		if (foreignKeyItemProvider != null) foreignKeyItemProvider.dispose();
		if (sqlIndexColumnItemProvider != null) sqlIndexColumnItemProvider.dispose();
		if (primaryKeyItemProvider != null) primaryKeyItemProvider.dispose();
		if (rowItemProvider != null) rowItemProvider.dispose();
		if (columnValueItemProvider != null) columnValueItemProvider.dispose();
		if (checkConstraintItemProvider != null) checkConstraintItemProvider.dispose();
		if (rowSetItemProvider != null) rowSetItemProvider.dispose();
		if (sqlParameterItemProvider != null) sqlParameterItemProvider.dispose();
		if (relational_containerItemProvider != null) relational_containerItemProvider.dispose();
	}

}
